Version 2.4 has made some changes to the callback utilities. Existing compiled 2.3 XFuns will still work with 2.4. Prototypes for callbacks have changed so you will need to change your source slightly to re-compile with the new headers.
The type for floating point parameters has been changed from "extended" to "double". The compiler must be set so that "double" means 80-bit for 68K code (or 64-bit for PowerPC code). The "extended" type was originally used to try to force the compiler to use 80-bit regardless of its settings. Using "double" makes it easier to switch between 68K and PowerPC.
The function return type has been changed from "BOOL" to "short". This is still a just TRUE or FALSE flag but the extra complication of providing a BOOL definition just confuses the issue.
A "uses globals" version of the callbacks has been provided via files "callbackg.h" and "callbackg.c". This is intended for cases where the XFun needs to use globals anyway. It is more convienient to save the callback pointer in a global rather than pass it as a parameter every time. The files "A4globs.h" and "entry.c" provide a generic way to handle setting and restoring A4. These A4 files have been tried with Think C 5 and CodeWarrior 8. For other compilers you are on your own.
For simple cases where you can avoid globals entirely, the files "callback.h" and "callback.c" provide the interface with the callback passed as parameter. Note: if you use CodeWarrior you must set the option for PC relative strings, otherwise strings will need A4 globals.
To illustrate the different styles of callbacks, the linfit example can be compiled using any of the 3 choices.
linfit68K. -- XFun without A4 globals
linfit src: linfit68K.c
util src: callback.c
<MacOS.lib>
linfit68Kg. -- XFun with A4 globals
linfit src: linfit68Kg.c
util src: callbackg.c
<MathLib68K (2i).A4.Lib>
<MacOS.lib>
linfitPPC. -- CFun powerPC code fragment
linfit src: linfitppc.c
:: MathPadPPC
<InterfaceLib>
<MathLib>
----------------------------------
New callbacks have been added. The major new XFun hook in version 2.4 is the ability to access events. This allows XFuns to display windows etc. See the file "Event Handlers" for more information.
There are also a few new general purpose callbacks:
Sticks a PICT to specific data coordinates rather than having it always re-size to Xmin, Xmax, Ymin, Ymax. No warning is generated if the PICT is placed outside the visible area.
void GetAngleUnits(double *unit)
Gets the currently selected multiplier for trig function angles. 1.0 for radians, .017 for degrees. This allows XFuns with angle parameters to switch angle units based on the user's selection.
short Sprintf(char *buf,char *fmt,double num);
Allows an XFun some access to sprintf() without linking its own ANSI library.
void ReturnVoid(void)
Sets a flag so that the XFun can return false and MathPad will not report an error. This is for cases where the XFun is for side effect only and has no useful function return value. (This flag is automatically set by calls to SetVarVal() or SetVarMatrix() but XFuns that only draw in windows might not call these routiines).
void GetAxisRect(Rect *axisrect);
Get the current data axis rectangle in plot window coordinates. This rectangle will be empty if there has never been a plot. An Xfun can force a plot with SetPlotPICT(NULL).
void GetAxisLimits(double limits[6]);
Get the the current values of xmin,xmax,ymin,ymax,zmin,zmax. These values will contain the scaling info from the last plot made. This allows access to auto ranged values.
void GetPlotInfo(double info[12]);
Get the the current values of xlo,xhi,ylo,yhi,zlo,zhi,traceclick,xclick,yclick,zclick, ixclick,iyclick. The values of xclick and zclick are set to -INF before each evaluation. The click values get set by a mousedown event AFTER evaluation so are really only useful to an event handler.